<?php
/**
 * 前台用户实例
 *
 * PHP Version 5
 *
 * @package    Shop
 * @subpackage Models
 * @author     Weber Liu <weber.liu@gmail.com>
 * @author     Scott Ye <yelin@ec3s.com>
 * @copyright  2010 Xingchangxinda Inc.
 * @version    SVN:$Id: backenduser.php 5128 2011-03-10 09:48:57Z weberliu $
 */

namespace Project\Apps\Ecga\Library;

use \Framework\System\Abstractions\User;
use \Project\Apps\Ecga\Library\EcgaPassport;
use \Project\Apps\Ecga\Application;

/**
 * 前台用户实例
 *
 * @package    Shop
 * @subpackage Models
 * @author     Weber Liu <weber.liu@gmail.com>
 * @author     Scott Ye <yelin@ec3s.com>
 * @copyright  2010 Xingchangxinda Inc.
 * @version    Release: v0.1
 */
class Visitor extends User
{
    /**
     * 创建当前用户使用的Passport
     *
     * @param Session $session Session实例
     *
     * @return Passport
     */
    protected function createPassport($session)
    {
        return new EcgaPassport;
    }
    /**
     * 取用户名
     *
     * @return string
     */
    protected function getUserName()
    {
        return $this->entity->userName;
    }
    /**
     *  判断是否是Boss帐号
     *
     * @author Wanggeng <wanggeng@ec3s.com>
     *
     * @return bool
     */
    public function isBoss()
    {
        $isBoss = false;

        if (1 == $this->userId) {
            $isBoss = true;;
        }
        return $isBoss;
    }
    /**
     * 获取当前用户的会话对象
     *
     * @return Sessions $session
     */
    protected function getSession()
    {
        return Application::getInstance()->createSession();
    }
}
